package com.example.zzl.model.HomeFragment;

import android.content.Context;
import android.util.Log;

import com.android.volley.Response;
import com.android.volley.toolbox.StringRequest;
import com.example.zzl.model.BaseModel;
import com.example.zzl.model.bean.SpecialInfo;
import com.example.zzl.model.cans.HomeUrl;
import com.example.zzl.utils.specification.VolleySingleton;
import com.example.zzl.viewmodel.BaseViewModel;
import com.google.gson.Gson;

/**
 * Created by ligg on 2017/2/11.
 */

public class SpecialInfoModel extends BaseModel implements Response.Listener<String> {

    private SpecialInfo info;

    public SpecialInfoModel(Context context, BaseViewModel callback) {
        super(context, callback);
    }

    @Override
    public void loadData(String parameter) {
        StringRequest stringRequest = new StringRequest(HomeUrl.infoHotSpecial + parameter, this, VolleySingleton.volleySingleton);
        VolleySingleton.volleySingleton.getRequestQueue().add(stringRequest);
    }


    @Override
    public void onResponse(String response) {
        Log.e("SpecialInfoModel", "onResponse: " + response);



        info = new Gson().fromJson(response, SpecialInfo.class);
        callback.loadFinished();
    }

    public SpecialInfo getInfo() {
        return info;
    }

    public void setInfo(SpecialInfo info) {
        this.info = info;
    }
}
